package com.qf.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.mapper.DtsFootprintMapper;
import com.qf.pojo.DtsFootprint;
import com.qf.service.AdminFootprintService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class AdminFootprintServiceImpl implements AdminFootprintService {

    @Autowired
    private DtsFootprintMapper dtsFootprintMapper;

    @Override
    public IPage<DtsFootprint> selectFootprintList(Integer page, Integer limit, Integer userId, Integer goodsId, String sort, String order) {

        IPage<DtsFootprint> iPage = new Page<>(page, limit);

        QueryWrapper<DtsFootprint> wrapper = new QueryWrapper<>();

        wrapper.eq("deleted", false);
        wrapper.orderByAsc("asc".equalsIgnoreCase(order),sort);
        wrapper.orderByDesc("desc".equalsIgnoreCase(order),sort);
        wrapper.eq(userId!= null, "user_id", userId);
        wrapper.eq(goodsId!= null, "goods_id", goodsId);

        IPage<DtsFootprint> result = dtsFootprintMapper.selectPage(iPage, wrapper);

        return result;
    }
}
